import com.alibaba.fastjson.JSONObject;

import java.io.*;
import java.util.HashMap;
import java.util.Map;


public class JsonUtils {
    public static String getJson(String path) {
        String jsonStr = "";
        try {
            File file = new File(path);
            FileReader fileReader = new FileReader(file);
            Reader reader = new InputStreamReader(new FileInputStream(file),"Utf-8");
            int ch = 0;
            StringBuffer sb = new StringBuffer();
            while ((ch = reader.read()) != -1) {
                sb.append((char) ch);
            }
            fileReader.close();
            reader.close();
            jsonStr = sb.toString();
            return jsonStr;
        } catch (Exception e) {
            System.out.println(e.toString());
            return null;
        }
    }

    public static JSONObject getJsonObj(String path){
        String json = getJson(path);
        JSONObject jsonObject = JSONObject.parseObject(json);
//        Map<String,Object> map = JSONObject.parseObject(jsonObject.toJSONString());
        return jsonObject;
    }
}
